#include <stdio.h>
#include <stdlib.h>
typedef char ElemType;

typedef struct TreeNode
{
    ElemType data;
    struct TreeNode *lchild;
    struct TreeNode *rchild;
}TreeNode;

typedef TreeNode *BiTree;

char str[] = "ABDH#K###E##CFI###G#J##";
int idx = 0;

void createTree(BiTree *T)
{
    ElemType ch;
    ch = str[idx++];
    if(ch == '#')
    {
        *T = NULL;
    }
    else
    {
        *T = (BiTree)malloc(sizeof(TreeNode));
        (*T)->data = ch;
        createTree(&(*T)->lchild);
        createTree(&(*T)->rchild);
    }
}

// 前序遍历
void PreOrder(BiTree T)
{
    if(T == NULL)
    {
        return;
    }
    printf("%c",T->data);
    PreOrder(T->lchild);
    PreOrder(T->rchild);
}

// 中序遍历
void InOrder(BiTree T)
{
    if(T == NULL)
    {
        return;
    }
    InOrder(T->lchild);
    printf("%c",T->data);
    InOrder(T->rchild);
}

// 后序遍历
void PostOrder(BiTree T)
{
    if(T == NULL)
    {
        return;
    }
    PostOrder(T->lchild);
    PostOrder(T->rchild);
    printf("%c",T->data);
}



int main()
{
    BiTree T;
    createTree(&T);
    PreOrder(T);
    printf("\n");
    InOrder(T);
    printf("\n");
    PostOrder(T);
    printf("\n");
    return 0;
}